class Solution:
    def lengthLongestPath(self, input: str) -> int:
        input = input.split("\n")
        maxFileLen = 0
        dirLen = []
        for i in input:
            nowLevel = 0
            k = 0
            while k+1<len(i) and '\t'==i[k]:
                nowLevel+=1
                k+=1
            dirLen[nowLevel:] = [len(i)-k+1]
            if '.' in i:
                maxFileLen = max(maxFileLen, sum(dirLen)-1)
        return maxFileLen



if __name__ == '__main__':
    so = Solution()
    s = "dir\n\t        file.txt\n\tfile2.txt"
    r = so.lengthLongestPath(s)
    print(r)
    print(len("        file.txt"))
